﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Data;

namespace Bussiness_Objects
{
    /// <summary>
    /// Thong tin table PHIEUTRASACH
    /// --PHIEUTRASACH(SoPT,MaDocGia,NgayTra,TienPhatKyNay,TienNoKyNay)
    /// </summary>
    public class PhieuTraSach : BusinessObjects
    {
        public PhieuTraSach()
        {
         
        }

        public PhieuTraSach(int _soPT, int _maDG, string _ngTra, long _tienPhat, long _tienNo)
        {
            SoPT = _soPT;
            MaDocGia = _maDG;
            NgayTra = _ngTra;
            TienNoKyNay = _tienNo;
            TienPhatKyNay = _tienPhat;
        }

        public void SetParameterSelectID()
        {
            SetParameterDelete();
        }

        public override void SetParameterInsert()
        {
            parms = new object[5];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;

            _parm = new SqlParameter(parNgayTra, NgayTra);
            parms[1] = _parm;

            _parm = new SqlParameter(parTienPhatKKyNay, TienPhatKyNay);
            parms[2] = _parm;

            _parm = new SqlParameter(parSoTienTra, SoTienTra);
            parms[3] = _parm;

            _parm = new SqlParameter();
            _parm.ParameterName = parSoPT;
            _parm.SqlDbType = SqlDbType.Int;
            _parm.Direction = ParameterDirection.Output;
            parms[4] = _parm;
        }

        public override void SetParameterUpdate()
        {
            parms = new object[5];
            SqlParameter _parm = new SqlParameter(parMaDocGia, MaDocGia);
            parms[0] = _parm;

            _parm = new SqlParameter(parNgayTra, NgayTra);
            parms[1] = _parm;

            _parm = new SqlParameter(parTienPhatKKyNay, TienPhatKyNay);
            parms[2] = _parm;

            _parm = new SqlParameter(parSoTienTra, SoTienTra);
            parms[3] = _parm;

            _parm = new SqlParameter(parSoPT, SoPT);
            parms[4] = _parm;
        }

        public void SetParameterDelete()
        {
            parms  = new object[1];
            SqlParameter _parm = new SqlParameter(parSoPT, SoPT);
            parms[0] = _parm;
        }

        public int SoPT { get; set; }
        private const string parSoPT = "@SoPT";

        public int MaDocGia { get; set; }
        private const string parMaDocGia = "@MaDocGia";

        public string NgayTra { get; set; }
        private const string parNgayTra = "@NgayTra";

        public long TienPhatKyNay { get; set; }
        private const string parTienPhatKKyNay = "@TienPhatKiNay";

        public long TienNoKyNay { get; set; }
        private const string parTienNoKyNay = "@TienNoKiNay";

        public long SoTienTra { get; set; }
        private const string parSoTienTra = "@SoTienTra";
    }
}
